<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            height: 500px;
            width: 500px;
            margin: 100px auto;
        }

        .top {
            height: 80px;
            display: flex;
            justify-content: space-between;
        }

        .top .biaoti {
            font-size: 20px;
            font-weight: 700;
            color: black;
            line-height: 80px;
        }

        .top .biaoti span:nth-child(2) {
            font-size: 20px;
            font-weight: 700;
            color: lightgray;
            line-height: 80px;
            margin-left: 5px;
        }

        .top .change {
            font-size: 14px;
            font-weight: 700;
            color: gray;
            border: none;
            background: none;
            cursor: pointer;
        }

        ul {
            list-style: none;
            opacity: 1;
            transition: 1s;
        }

        ul li {
            margin-bottom: 10px;
        }

        ul li span {
            color: grey;

            margin-right: 5px;
        }

        ul li:nth-child(1)>span {
            color: red;
        }

        ul li:nth-child(2)>span {
            color: rgb(255, 38, 0);
        }

        ul li:nth-child(3)>span {
            color: rgb(255, 89, 0);
        }

        ul li:nth-child(4)>span {
            color: rgba(255, 153, 0, 0.932);
        }

        li a {
            font-size: 16px;
            color: blue;
            text-decoration: none;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="top">
            <div class="biaoti"><span>百度热搜</span><span>&gt;</span></div>
            <button class="change">换一换</button>
        </div>
        <ul class="list">
            <!-- <li>
                <span>⬆</span>
                <a href="#">继续为各国来华投资提供便利</a>
            </li>
            <li>
                <span>1</span>
                <a href="#">乌市一方舱有卖淫嫖娼？警方回应</a>
            </li>
            <li>
                <span>2</span>
                <a href="#">“红月亮”遇上月掩天王星</a>
            </li>
            <li>
                <span>3</span>
                <a href="#">前10个月进出口同比增长9.5%</a>
            </li>
            <li>
                <span>4</span>
                <a href="#">湖南一中学多名学生感染 校长被免职</a>
            </li>
            <li>
                <span>5</span>
                <a href="#">俄罗斯制裁74家外国公司</a>
            </li>
            <li>
                <span>6</span>
                <a href="#">深圳楼市双11也打折</a>
            </li>
            <li>
                <span>7</span>
                <a href="#">钟琰琰再度成为中国首富</a>
            </li>
            <li>
                <span>8</span>
                <a href="#">两名15岁学生被清华录取硕博连读</a>
            </li>
            <li>
                <span>9</span>
                <a href="#">首尔地铁人群混乱 有人喊喘不过气了</a>
            </li>
            <li>
                <span>10</span>
                <a href="#">男子月薪5万试用3天被解雇</a>
            </li> -->

        </ul>
    </div>
</body>

</html>
<script>
    var arr = [
        { xuhao: "⬆", text: "继续为各国来华投资提供便利" },
        { xuhao: 1, text: "“红月亮”遇上月掩天王星" },
        { xuhao: 2, text: "前10个月进出口同比增长9.5%" },
        { xuhao: 3, text: "湖南一中学多名学生感染 校长被免职" },
        { xuhao: 4, text: "俄罗斯制裁74家外国公司" },
        { xuhao: 5, text: "深圳楼市双11也打折" },
        { xuhao: 6, text: "钟琰琰再度成为中国首富" },
        { xuhao: 7, text: "两名15岁学生被清华录取硕博连读" },
        { xuhao: 8, text: "首尔地铁人群混乱 有人喊喘不过气了" },
        { xuhao: 9, text: "男子月薪5万试用3天被解雇" }

    ]
    function render() {

        var list = document.querySelector('ul');
        var str = ``
        for (var i = 0; i < arr.length; i++) {
            str += ` 
            <li>
                <span>${arr[i].xuhao}</span>
                <a href="#">${arr[i].text}</a>
            </li>
          `
        }
        list.innerHTML = str

    }
    render()

    // var list = document.querySelector('ul');
    //     list.innerHTML = arr.map((item,index) => {
    //         return
    //         ` 
    //         <li>
    //             <span>${item.xuhao}</span>
    //             <a href="#">${item.text}</a>
    //         </li>
    //       `
    //     }).join('')
    var box = document.querySelector('.box')
    var btn = document.querySelector('.change')
    var flag = true

    btn.onclick = () => {
        this.flag = !this.flag;
        if (flag == false) {
            document.querySelector('ul').style.opacity = 0
            document.querySelector('ul').style.transition = '1s'
        }
        else {
            document.querySelector('ul').style.opacity = 1
        }
    }

</script>